<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title><?php echo $title;?></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../public/plugin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../public/css/base.css">
  <link rel="stylesheet" href="../../public/icon1/demo.css">
  <link rel="stylesheet" href="../../public/icon1/iconfont.css">
  <script src="../../public/icon1/iconfont.js"></script>
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header" style="padding-top:30px;font-size:18px;"><?php echo $title;?>
		  <div style="float:right;padding-right:20px;">
				<button class="layui-btn layui-btn-normal" id="add"><span class="iconfont icon-plus-circle" ></span>&nbsp;添加</button>
			</div>
		  </div>
          <div class="layui-card-body" pad15>
			<table class="layui-table">
			  <thead>
				<tr>
				  <th>id</th>
				  <th>题型分类</th>
				  <th>操作</th>
				</tr> 
			  </thead>
			  <tbody>
			  <?php foreach($list as $k => $v):?>
				<tr>
				  <td><?php echo $v['id'];?></td>
				  <td><?php echo $v['type_name'];?></td>
				  <td>
					<div class="layui-btn-container">
					  <button class="layui-btn layui-btn-sm" index="<?php echo $v['id'];?>" onclick="Delete(this)">删除</button> 
					</div>
				  </td>
				</tr>
			<?php endforeach;?>
				<tr>
					<td colspan="3">
					<div class="pages">
					  <?php echo $strPage;?>
					</div>
					</td>
				</tr>
			  </tbody>
			</table>
			
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>
<script src="../../public/js/jquery.js"></script>
<script src="../../public/plugin/layer/layer.js"></script>
<script>
	$(function() {
		//给按钮绑定单击事件
		$('#add').on('click', function() { 
			layer.open({
				type: 2,
				title: '添加类型',
				shadeClose: true,
				maxmin:true,
				shade: 0.8,
				area: ['800px', '60%'],
				content: "add_qtype.php", //iframe的url
			});
		});
	})
</script>

<script>
	function Delete(btn){
		var index = btn.getAttribute("index");
		var id = Number(index);
		var tr = btn.parentNode.parentNode.parentNode;
		/*if(confirm("确定删除吗？")){
			$.ajax({
				type:'GET',
				url:'ajaxdeleteqtype.php?id='+id,
				success:function(data){
					layer.msg(data,{icon: 6,time:2000});
					tr.remove();
				}
				});
			}
		*/
		layer.confirm("确定删除吗？",function(){
			$.ajax({
				type:'GET',
				url:'ajaxDeleteQType.php?id='+id,
				success:function(data){
					if(data=='<span style="color:green;">删除成功</span>'){
						layer.msg(data,{icon: 6,time:2000});
						tr.remove();
					}else{
						layer.msg(data,{icon: 5,time:2000});
					}
					
				}
			});
		});
		
		}
</script>